home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Inquiry.c - get identification from hard drive using HD_SCSICMD
- ** Copyright (C) 1988 by Ralph Babel, Falkenweg 3, D-6204 Taunusstein, FRG
- ** all rights reserved - alle Rechte vorbehalten
- **
- ** 25-Oct-1988 created
- */
-
- /*** included files ***/
-
- #include <exec/types.h>
- #include <exec/io.h>
- #include <exec/memory.h>
- #include <devices/scsidisk.h>
- #include <libraries/dos.h>
- #include <proto/exec.h>
- #include <proto/dos.h>
-
- /*** external symbol references ***/
-
- void fprintf(BPTR, const char *, ...);
-
- /*** constants ***/
-
- #define BOARD 0 /* controller board */
- #define TID 0 /* SCSI target ID */
- #define LUN 0 /* logical unit */
-
- #define UNIT (BOARD * 100 + LUN * 10 + TID)
-
- #define MAXBUF 252
-
- /*** entry point (RXStartUp.obj) ***/
-
- void __stdargs __saveds main(
- ULONG argc,
- const char *const argv[])
- {
- BPTR fh;
- UBYTE *scsidata;
- UBYTE *sensedata;
- struct MsgPort *mp;
- struct IOStdReq *io;
- struct SCSICmd SC;
- UBYTE command[6];
- UWORD i;
-
- if(argc != 0) /* CLI only! */
- {
- fh = Output();
-
- if((scsidata = AllocMem(MAXBUF, MEMF_CHIP)) != NULL)
- {
- if((sensedata = AllocMem(MAXBUF, MEMF_CHIP)) != NULL)
- {
- if((mp = CreatePort(NULL, 0)) != NULL)
- {
- if((io = CreateStdIO(mp)) != NULL)
- {
- if(OpenDevice("gvpscsi.device", UNIT, (struct IORequest *)io, 0) == 0)
- {
- io->io_Command = HD_SCSICMD;
- io->io_Length = sizeof(struct SCSICmd);
- io->io_Data = (APTR)&SC;
-
- SC.scsi_Data = (UWORD *)scsidata;
- SC.scsi_Length = MAXBUF;
- SC.scsi_Command = command;
- SC.scsi_CmdLength = 6;
-
- #ifdef SCSIF_AUTOSENSE
-
- SC.scsi_Flags = SCSIF_READ | SCSIF_AUTOSENSE;
- SC.scsi_SenseData = sensedata;
- SC.scsi_SenseLength = MAXBUF;
- SC.scsi_SenseActual = 0;
-
- #else
-
- SC.scsi_Flags = SCSIF_READ;
-
- #endif
-
- command[0] = 0x12; /* INQUIRY */
- command[1] = LUN << 5;
- command[2] = 0;
- command[3] = 0;
- command[4] = MAXBUF;
- command[5] = 0;
-
- (void)DoIO((struct IORequest *)io);
-
- fprintf(fh, "io_Error = %d\n", io->io_Error);
- fprintf(fh, "scsi_Status = %d\n", SC.scsi_Status);
- fprintf(fh, "scsi_CmdActual = %d\n", SC.scsi_CmdActual);
- fprintf(fh, "scsi_Actual = %ld\n", SC.scsi_Actual);
-
- #ifdef SCSIF_AUTOSENSE
-
- fprintf(fh, "scsi_SenseActual = %d\n", SC.scsi_SenseActual);
-
- if(SC.scsi_SenseActual != 0)
- {
- fprintf(fh, "\nSenseData:");
-
- for(i = 0; i < SC.scsi_SenseActual; ++i)
- fprintf(fh, " %02x", sensedata[i]);
-
- fprintf(fh, "\n");
- }
-
- #endif
-
- if(io->io_Error == 0)
- {
- fprintf(fh, "\n");
-
- for(i = 0; i < 5; ++i)
- fprintf(fh, "%d: $%02x\n", i, scsidata[i]);
-
- fprintf(fh, "\n");
-
- for(i = 5; i < SC.scsi_Actual; ++i)
- fprintf(fh, "%c", scsidata[i] != 0? scsidata[i]: '.');
-
- fprintf(fh, "\n");
- }
-
- CloseDevice((struct IORequest *)io);
- }
- else
- fprintf(fh, "Error %d while opening SCSI unit %ld.\n",
- io->io_Error, (long)UNIT);
-
- DeleteStdIO(io);
- }
- else
- fprintf(fh, "Could not create I/O request.\n");
-
- DeletePort(mp);
- }
- else
- fprintf(fh, "Could not create message port.\n");
-
- FreeMem(sensedata, MAXBUF);
- }
- else
- fprintf(fh, "Insufficient free store.\n");
-
- FreeMem(scsidata, MAXBUF);
- }
- else
- fprintf(fh, "Insufficient free store.\n");
- }
- }
-